<template>
  <div>
    <city-header></city-header>
    <city-search :cities= "cities"></city-search>
    <city-list :hot="hot" :cities="cities" :letter="letter"></city-list>
    <city-alphabet :cities="cities" @change="receive"></city-alphabet>
  </div>
</template>

<script>
import axios from "axios";
import CityHeader from "./cityheader";
import CitySearch from "./citysearch";
import CityList from "./citylist";
import CityAlphabet from "./cityalphabet";
export default {
  name: "City",
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet,
  },
  data() {
    return {
      cities: {},
      hot: [],
      letter: "",
    };
  },
  methods: {
    getCityInfo() {
      axios.get("/api/city.json").then(this.getCityInfoSucc);
    },
    getCityInfoSucc(res) {
      res = res.data;
      if (res.ret && res.data) {
        this.cities = res.data.cities;
        this.hot = res.data.hotCities;
      }
      console.log(res);
    },
    receive(letter) {
      // console.log(letter);
      this.letter = letter;
    },
  },
  mounted() {
    this.getCityInfo();
  },
};
</script>

<style scoped>
</style>